'use client'
import Loading from '../components/base/loading'
import classNames from '@/utils/classnames'
import { login } from '@/service/common'

const init = async () => {
  const urlSearchParams = new URLSearchParams(window.location.search)
  const memberProject = JSON.parse(urlSearchParams.get('memberProject') as string)
  let loginData: Record<string, any> = {}
  loginData = { ...memberProject }
  const res = await login({
    url: '/ssoLogin',
    body: loginData,
  })
  if (res.result === 'success') {
    localStorage.setItem('console_token', res.data.access_token)
    localStorage.setItem('refresh_token', res.data.refresh_token)
    window.location.href = '/apps'
  }
}
init()
const Install = () => {
  return (
    <div style={{ animation: 'revealText 3s forwards', textAlign: 'center', backgroundColor: 'url("/logo/logo-embedded-chat-avatar.png")' }} className={classNames(
      'flex w-full min-h-screen',
      'p-4 lg:p-8',
      'gap-x-20',
      'justify-center lg:justify-start',
    )}>
      <div className="block m-auto w-96">
        <Loading />
      </div>
    </div>
  )
}

export default Install
